class NumberContainers {
public:
    NumberContainers() {}

    void change(int index, int number) {
        _hash[index] = number;
        _hashq[number].push(index);
    }

    int find(int number) {
        while (_hashq[number].size()) {
            int i = _hashq[number].top();
            if (_hash[i] == number) return i;
            else _hashq[number].pop();
        }
        return -1;
    }

private:
    unordered_map<int, priority_queue<int, vector<int>, greater<int>>> _hashq;
    unordered_map<int, int> _hash;
};

/**
 * Your NumberContainers object will be instantiated and called as such:
 * NumberContainers* obj = new NumberContainers();
 * obj->change(index,number);
 * int param_2 = obj->find(number);
 */